//
//  BaseViewController.m
//  DriftDog
//
//  Created by rimi on 15/9/7.
//  Copyright (c) 2015年 廖马林. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

- (void)initializeUserInterfaces;

@end

@implementation BaseViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self initializeUserInterfaces];
}

#pragma mark - init

- (void)initializeUserInterfaces {

    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.baseNavigationBar];
}

#pragma mark - interface methods

- (void)addTitleLabelWithName:(NSString *)title {

    UILabel *titleLabel = [[UILabel alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0, 0, 115, 28), NO)];
    titleLabel.center = CGPointMake(self.baseNavigationBar.center.x, self.baseNavigationBar.center.y + 6 * DHFlexibleVerticalMutiplier());
    titleLabel.text = title;
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.font = [UIFont boldSystemFontOfSize:DHFlexibleVerticalMutiplier() * 20];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    
    [self.baseNavigationBar addSubview:titleLabel];
}

- (void)addBaseLeftButtonWithImage:(UIImage *)image {

    self.baseLeftButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _baseLeftButton.frame = DHFlexibleFrame(CGRectMake(30, 22 + 11 * DHFlexibleVerticalMutiplier(), 25, 25), NO);
    [_baseLeftButton setImage:image forState:UIControlStateNormal];
    
    [self.baseNavigationBar addSubview:_baseLeftButton];
}

- (void)addBaseRightButtonWithImage:(UIImage *)image {

    self.baseRightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _baseRightButton.frame = DHFlexibleFrame(CGRectMake(ORIGIN_WIDTH - 60, 20 + 12 * DHFlexibleVerticalMutiplier(), 30, 30), NO);
    [_baseRightButton setImage:image forState:UIControlStateNormal];
    
    [self.baseNavigationBar addSubview:_baseRightButton];
}

#pragma mark - getter

- (UIView *)baseNavigationBar {
    
    if (!_baseNavigationBar) {
        
        _baseNavigationBar = [[UIView alloc] initWithFrame:DHFlexibleFrame(CGRectMake(0, 0, ORIGIN_WIDTH, 75), NO)];
        _baseNavigationBar.backgroundColor = [UIColor colorWithRed:220 / 255.f green:86 / 255.f blue:13 / 255.f alpha:1];
    }
    return _baseNavigationBar;
}

@end
